package com.ctshk.common.enums.appUser;

import java.util.Arrays;

/**
 * <p>
 * c端订单状态枚举
 * </p>
 *
 * @author 李新科
 * @since 2021/5/29
 */
public enum AppOrderStatus {
    UN_PAYMENT(1, "待付款","訂單生成待旅客付款"),
    UN_CONFIRM(2, "您已下單，等待確認","訂單生成，等待出票確認(二次確認產品，不包含旅行團、機場快線)"),
    PAYMENT(3, "已付款","訂單生成，付款完成出票(旅行團、機場快線)"),
    UN_SHIP(4, "待发货","支付後，商品待發貨(商品)"),
    SHIP(5, "已发货","支付後，部分商品發貨(商品)"),
    UN_RECEIPT(6, "待收货","部分全部商品發貨，待收貨(商品)"),
    UN_PICK_UP(7, "待提货","支付後，自己去門店提貨(商品)"),
    RESERVE_FAIL(8, "预订失败","旅客已付款，訂單確認失敗(不包含旅行團的其他業務)"),
    TIME_OUT_CANCEL(9, "超时未付款,订单已取消","待確認狀態進入已完成狀態(不包含旅行團的其他業務)"),
    SUCCESS(10, "已完成","預訂成功/已收貨/已提貨(不包含旅行團、機場快線的其他業務)"),
    UN_HANDLE(11, "待处理","旅客發起退款申請，審批不通過回到原本狀態"),
    UN_REFUND(12, "待退款","審批通過等待退款"),
    REFUND_SUCCESS(13, "已退款","已退款成功"),
    ;

    private Integer code;
    private String name;
    private String desc;

    AppOrderStatus(Integer code, String name,String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    /**
     * 通过key拿订单状态名称
     * gzl-wansi001
     * @param code
     * @return
     */
    public static String getOrderStatusName(Integer code){
        AppOrderStatus orderStatus = Arrays.stream(AppOrderStatus.values())
                .filter(enums -> enums.getCode().equals(code)).findFirst().orElse(null);

        if(orderStatus != null){
            return orderStatus.getName();
        }
        return "";
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


}
